package net.googlecode.demenkov.task4.utils;

import net.googlecode.demenkov.task4.source.StringUtil;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * StringUtil that inputs date that below current on 20 days and log it.
 *
 * @author Yura Demenkov
 * @since 04.04.11
 */
public class InputDate extends StringUtil {
    /**
     * Ms in 20 days.
     */
    private long msIn20Days = 20 * 24 * 60 * 60 * 1000;

    /**
     * Constructor that create StringUtil and assosiate it with inputstring.
     *
     * @param inputstring
     */
    public InputDate(String inputstring) {
        super(inputstring);
    }

    /**
     * Inputs date that below current on 20 days and log it.
     *
     * @return Corrected striing.
     */
    public String InputDateAfterDot() {
        String outputString = new String();
        StringBuilder sb = new StringBuilder();
        sb.append(inputString);
        Date date = new Date(System.currentTimeMillis() - msIn20Days);
        SimpleDateFormat formatter;
        formatter = new SimpleDateFormat("dd.MM.yy H.mm");
        sb.append(" " + formatter.format(date));
        outputString = sb.toString();
        this.LogMessage(outputString, "Inputs date that below current on 20 days in the end of line.");
        return outputString;
    }
}
